package hu.berczi.Utils.Coordinates.planar;

import java.awt.geom.Point2D;

public class Vector {
	private Point2D.Double direction;

	/*
	 * Returns the angle of the vector in degrees.
	 */
	public double getAngle() {

		double angle = Math.atan((direction.getX() / direction.getY()));
		return angle;
	}

	/*
	 * TODO
	 */
	public void setAngle(double angle) {

	}

	public double getLength() {
		return (double) direction.distance(0, 0);
	}

	/*
	 * returns: old length
	 */
	public double setLength(double length) {
		double oldLength = this.getLength();
		if (length != oldLength && oldLength != 0) {

			this.direction.setLocation(this.direction.getX()
					* (length / oldLength), this.direction.getY()
					* (length / oldLength));
		}
		return oldLength;
	}

	public Point2D.Double getDirection() {
		return direction;
	}

	public void setDirection(Point2D.Double direction) {
		this.direction = direction;
	}

	public void setDirectionX(double newX) {
		this.direction.setLocation(newX, this.direction.getY());
	}

	public void setDirectionY(double newY) {
		this.direction.setLocation(this.direction.getX(), newY);
	}

}
